/*
 *  DEV changelog
 *
 *  08.04.11 - JT : Adding function trackImpression to populate omniture variable 'prop29' (page state)
 *  08.12.11 - JT : Adding code to clear 'prop29' in function 'clearOmniture()'
 *  */

// TEMPORARY FREEZE OVERRIDE
function unFreezePage() {}
function freezePage() {
	popOpen('busyIndicator'); 
	document.getElementById('busyIndicator').style.cursor = "wait"; 
	
	var delayedFunction = function () {popClose('busyIndicator'); document.getElementById('busyIndicator').style.cursor = "default";}
	
	setTimeout(delayedFunction, 1500);
}




// omniture.js
var debugMode = getURLParameter('OmnitureDebug');

// To store the page name to be passed in feedback url
var pageName = "";
var hierarchy = "";

// To store the eSpotPageImpressionsList
var eSpotPageImpressionsList = ""; 

// To store the cmsSpotPageImpressionsList
var cmsSpotPageImpressionsList = "";

if(document.getElementById("globalNavigation") ) {

$$('li#shopMainNavSectionItems .subNavListingLink').each(function (e) {
					Event.observe(e, 'click', function(e) {
						var element = Event.element(e)			
						trackMainNavForOmniture('SHOP',element.id,element.name,'subNavListingLink',element.name,element.href);
						//Event.stop(e);
	});
});

$$('li#supportMainNavSectionItems .mainNavListingLink').each(function (e) {
					Event.observe(e, 'click', function(e) {
						var element = Event.element(e)			
						 trackMainNavForOmniture('SUPPORT',element.id,element.name,'mainNavListingLink',element.innerHTML,element.href);
						// Event.stop(e);
	});
});

$$('li#servicesMainNavSectionItems .subNavListingLink').each(function (e) {
					Event.observe(e, 'click', function(e) {
						var element = Event.element(e)			
						 trackMainNavForOmniture('SERVICES:Affiliate Programs',element.id,element.name,'subNavListingLink',element.innerHTML,element.href);
						// Event.stop(e);
	});
});
$$('li#servicesMainNavSectionItems .mainNavListingLink').each(function (e) {
					Event.observe(e, 'click', function(e) {
						var element = Event.element(e)			
						 trackMainNavForOmniture('SERVICES',element.id,element.name,'subNavListingLink',element.innerHTML,element.href);
						// Event.stop(e);
	});
});
$$('li#discoverMainNavSectionItems .mainNavListingLink').each(function (e) {
					Event.observe(e, 'click', function(e) {
						var element = Event.element(e)			
						 trackMainNavForOmniture('DISCOVER',element.id,element.name,'subNavListingLink',element.innerHTML,element.href);
						/// Event.stop(e);
	});
});

}


// Generic Link Tracking -- JK - 04-18-11 
//$$('a.trackedLink').invoke('observe', 'click', function (ev) {
//	Event.stop(ev);
//	var el = Event.element(ev);
//		if (el) {
//			_cmspotObject.trackCMSOmniture(el.href, el.rel, (el.target == "_blank"), ev);
//		}
//});

// Generic Link Tracking: Round 2 -- JK - 07-14-11
$$('a.trackedLink').each(function(el){
    var linkTracker = function (ev) {
        Event.stop(ev);
        _cmspotObject.trackCMSOmniture(el.href, el.rel, (el.target == "_blank"), ev);
    };

    el.observe('click', linkTracker);
});


/*	CID Tracking:
 *	Added by: Branden Thompson - 08.03.10
 *	Allows for populating a new eVar per Web Analytics request.
*/
var CID = getURLParameter('cid');

if (CID != ''){
	s.eVar30 = CID;
}

/*      Ad Parameter:
*       Allows for populating a new eVar per Web Analytics request.
*/
var ADPARAM = getURLParameter('adparam');

if (ADPARAM != ''){
	s.eVar47 = ADPARAM;
}


/*      Query String:
*       Allows for populating a new eVar per Web Analytics request.
*/
var QS = getURLParameter('qs');

if (QS != ''){
	s.eVar48 = QS;
}

/*      Kenshoo:
*       Allows for populating a new eVar per Web Analytics request.
*/
var KID = getURLParameter('k_id');

if (KID != ''){
s.eVar46 = KID;
}
	


/*	trackEduEppFCUser()
 *	------------------------------------------------------------------------
 *	PRE-CONDITIONS:			- 	Prototype.js must be included prior to this 
 *								function being called.
 *
 *	POST-CONDITIONS:		-	Will check for a certain <span> tag that is
 *								only writteon on the page when the user is 
 *								a valid Family Center, EPP or EDU user, or
 *								has come to the site through a proper 
 *								referring link that will enable to user to 
 *								browser an one of those types of users.
*/
function trackEduEppFCUser()
{
	/*	first, let's check to see if there is a bar in the header.  This
	 *	will allow us to be able to grab the inner HTML of stuff.
	 *
	 *	NOTE:  	The first if() conditional is to ensure we don't get a 
	 *			runtime error on MSIE browsers:
	*/
	if($('programStorefrontName')){
		if(($('programStorefrontName').innerHTML != null) || ($('programStorefrontName').innerHTML != ''))
		{
			/*	Since this SPAN tag only appears if the user has a valid 
			 *	EDU/EPP/FC cookie, we should now be clear to fire off 
			 *	this function.
			*/
			clearOmniture(s);
			s=s_gi(s_account);	
			s.linkTrackVars = "eVar4";	// eVar Specified for use by MS.
			s.linkTrackEvents="None";	// Currently no events to track
			
			
			/*	the innerHTML should say something like:
			 *	"Family Center Storefront"
			 *	"IBM Purchase Program Storefront"
			 *	"San Diego State University Storefront"
			 *
			 *	So let's grab this value and send it to Omniture.
			*/	
			s.eVar4 = $('programStorefrontName').innerHTML;
			s.tl(this, 'o', 'Store Context');
			//OmnitureDebug();
		}
	}
}

function trackMainNavForOmniture(dept,id,name,cssClass,text,href)	 {
	if(href != "" && href.startsWith('http') && text != "") {
	   text = text.unescapeHTML();
	    text = dept +':'+text;
	    text = text.replace(",",":");
	    //clearOmniture(s);
	    setpageName(pageName);
	    s = s_gi(s_account);
	    s.linkTrackVars = "eVar25";
	    s.linkTrackEvents = "None";
	    s.eVar25 = text;
	    s.tl(this,'o',pageName);
	    if (debugMode) {
	        window.open("", "stats_debugger", "width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=\"http://192.168.112.2o7.net/stats_debugger.php\"></script><script language=\"JavaScript\">window.focus();</script>");
	    }
	 }
}

function trackMainNavSimple(trackingDetails){
	clearOmniture(s);
	s=s_gi(s_account);
	s.linkTrackVars="eVar25";
	s.linkTrackEvents="None";
	s.eVar25=trackingDetails;
	s.tl(this,'o','CM Spots');
	if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");		
}

// to set the hierarchy of the page. 
function setHierarchy(hier)
{
hierarchy=hier;
}

// sets the pagename from omniture
function setpageName(pagename){
	pageName=pagename;
	
	}
// sets the espots 
function setEspotPageImpressionsList(espotName){
	eSpotPageImpressionsList=eSpotPageImpressionsList+espotName;

	}	

// gets the espots
function getEspotPageImpressionsList(){

	return eSpotPageImpressionsList;
	
	}
	
// sets the cmsspots 
function setCmsSpotPageImpressionsList(cmsspotname){
	cmsSpotPageImpressionsList=cmsSpotPageImpressionsList+cmsspotname;

	}	

// gets the cmsspots
function getCmsSpotPageImpressionsList(){

	return cmsSpotPageImpressionsList;
	
	}	

// opens the feedback URL
function  callFeedBackURL()
  {
    var url="http://sonystyle.custhelp.com/cgi-bin/sonystyle.cfg/php/xml_api/cci/feedback.php?source=";
    url=url+pageName;
   	window.open(url);
	
  } 


//
// Get all URL parameters
//
function getURLParameters()
{
	// get the current URL
	var url = window.location.toString();
	// get the parameters
	url.match(/\?(.+)$/);
	var params = RegExp.$1;
	// split up the query string and store in an associative array		
	var params = params.split("&");
	var url_params = {};			 			
		 
	for(var i=0; i<params.length; i++)
	{
		var tmp = params[i].split("=");
		url_params[tmp[0].toLowerCase()] = unescape(tmp[1]);
	}
	return url_params; 
}

//	
// Get a specific URL parameter if present	
//
function getURLParameter(name) 
{
	name = name.toLowerCase();
	url_params = getURLParameters();
	return (url_params[name] == undefined) ? '' : url_params[name];		
}

//
// Clear Omniture variables
//
function clearOmniture(s)
{
	s.pageName='';
	s.server='';
	s.channel='';
	s.pageType='';
	s.prop1=''; s.prop2='';	s.prop3='';	s.prop4='';	s.prop5='';	s.prop6=''; s.prop7=''; s.prop8='';	s.prop9='';	s.prop10=''; s.prop11=''; s.prop12=''; s.prop29='';
	s.hier1='';
	s.campaign='';
	s.state='';
	s.zip='';
	s.events='';
	s.products='';
	s.purchaseID='';
	s.eVar1='';	s.eVar2='';	s.eVar3='';	s.eVar4='';	s.eVar5='';	s.eVar6='';	s.eVar7='';	s.eVar8='';	s.eVar11=''; s.eVar12=''; 
	s.eVar13=''; s.eVar14=''; s.eVar15=''; s.eVar16=''; s.eVar17=''; s.eVar18='';	s.eVar19=''; s.eVar20=''; s.eVar21=''; s.eVar22='';
	s.eVar26='';s.eVar27='';s.eVar28='';s.evar36='';
}



// 
// Track promo bundle 
//
function trackPromoBundle()
{

	clearOmniture(s);
	s=s_gi(s_account);
	s.linkTrackVars="eVar28";
	s.linkTrackEvents="None";
	s.eVar28='vaio:summerbundle';
	
	s.tl(this,'o','PromoBundle');
	if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");		
}

function trackCMSpot(cmSpotName)
{
	try {
		clearOmniture(s);
		s=s_gi(s_account);
		s.linkTrackVars="eVar10";
		s.linkTrackEvents="None";
		s.eVar10=pageName+' > '+cmSpotName;
		//s.prop23=pageName+' > '+cmSpotName;
		s.tl(this,'o','CM Spots');
		if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");		
	} catch(e) { if (typeof console != "undefined") { console.log('exeption in omniture.js-fn:trackCMSpot')}};
}

/*  08.04.11 - JT
 *  Tracks any changes to page state.
 *
 *  Page state is any change on a page without being directed to a new URL.
 */
function trackImpression(cmSpotName)
{
    var me = this;

    try {
        clearOmniture(s);
        s=s_gi(s_account);
        s.linkTrackVars="prop29";
        s.linkTrackEvents="None";
        s.prop29=pageName+' > '+cmSpotName;
        s.tl(this,'o','RIA Links');
        if (debugMode) {
            window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");
        }
    } catch(e) {
        //debug('EXCEPTION fn:trackImpression '+cmSpotName, e);
    }
} // end trackImpression()

function trackEndecaCMSpot(ruleName)
{
	clearOmniture(s);
	s=s_gi(s_account);
	s.linkTrackVars="eVar35";
	s.linkTrackEvents="None";
	s.eVar35=pageName+' > '+ruleName;
	s.tl(this,'o','Endeca Rules');
	if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");		
}

function trackESpot(eSpotName)
{

	clearOmniture(s);
	s=s_gi(s_account);
	s.linkTrackVars="eVar5,prop6";
	s.linkTrackEvents="None";
	s.eVar5=pageName+' > '+eSpotName;
	s.prop6=pageName+' > '+eSpotName;


	s.tl(this,'o','E Spots');
	if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");		
}


function trackDealerLocator()
{
	clearOmniture(s);
	s=s_gi(s_account);
	s.linkTrackVars="events";
	s.linkTrackEvents="event4";
	s.events="event4";
	s.tl(this,'o','DealerLocator');
	if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");	
}

function trackAdvizia()
{
	clearOmniture(s);
	s=s_gi(s_account);
	s.linkTrackVars="events";
	s.linkTrackEvents="event13";
	s.events="event13";
	s.tl(this,'o','Advizia');
	if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");	
}

function trackLoginAttempt()
{
	if ((typeof s != 'undefined') && (s != undefined)) clearOmniture(s);
	s=s_gi(s_account);
	s.linkTrackVars="events";
	s.linkTrackEvents="event6";
	s.events="event6";
	s.tl(this,'o','LoginAttempt');
	if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");
}


function trackRegistrationAttempt()
{
	if ((typeof s != 'undefined') && (s != undefined)) clearOmniture(s);
	s=s_gi(s_account);
	s.linkTrackVars="events";
	s.linkTrackEvents="event7";
	s.events="event7";
	s.tl(this,'o','RegistrationAttempt');
	if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");
}

function trackAddToWishList(partNumber)
{
	clearOmniture(s);
	s=s_gi(s_account);
	s.linkTrackVars="events,products";
	s.linkTrackEvents="event8";
	s.events="event8";
	s.products=';'+partNumber;
	s.tl(this,'o','Add to WishList');
	if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");	
}

function trackSearchResults()
{
	clearOmniture(s);
	s=s_gi(s_account);
	s.linkTrackVars="events";
	s.linkTrackEvents="event5";
	s.events="event5";
	s.tl(this,'o','SearchResults');
	if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");	
}

function trackSonyCardReferrals()
{
	clearOmniture(s);
	s=s_gi(s_account);
	s.linkTrackVars="events";
	s.linkTrackEvents="event9";
	s.events="event9";
	s.tl(this,'o','SonyCardReferrals');
	if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");	
}

function trackCheckoutStart()
{
	var products = s.products;
	clearOmniture(s);
	s=s_gi(s_account);
	s.linkTrackVars="events,products";
	s.linkTrackEvents="scCheckout";
	s.events="scCheckout";
	s.products=products;
	s.tl(this,'o','CheckOutStart');
	if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");	
}

/*
function trackAddToShoppingCart(sku)
{
	var cartEvent = "scOpen";
	var openFlag = getCookie("SY_OMOC","");
	if (openFlag) {
	    cartEvent = "scAdd";
	    //alert("scAdd triggered");
	}
	else {
	    setCookie("SY_OMOC","true");
	    //alert("scOpen triggered");
	}	
	clearOmniture(s);
	s=s_gi(s_account);
	s.linkTrackVars="events,products";
	s.linkTrackEvents=cartEvent;
	s.events=cartEvent;
	s.products=';'+sku;
	s.tl(this,'o','AddToShoppingCart');
	if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");	
}
*/

function trackAddToShoppingCart(sku)
{	
	clearOmniture(s);
	s=s_gi(s_account);
	s.linkTrackVars="events,products";
	s.linkTrackEvents="scAdd";
	s.events="scAdd";
	s.products=';'+sku;  	
	s.tl(this,'o','AddToShoppingCart');
	if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");	
}

function trackRemoveFromCart(sku)
{
	clearOmniture(s);
	s=s_gi(s_account);
	s.linkTrackVars="events,products";
	s.linkTrackEvents="scRemove";
	s.events="scRemove";
	s.products=';'+sku;	
	s.tl(this,'o','RemoveFromCart');
	if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");	
}

function trackProductTab(sku,tabName)
{
	var productTabName = sku + ":" + tabName;
// commented for defect 7764 	
//	clearOmniture(s);  
//	s=s_gi(s_account);
	s.linkTrackVars="prop7";
	s.linkTrackEvents="prodView,event11";
	s.prop7=productTabName;
	s.tl(this,'o','Product Tabs');
	if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");	
}

function trackCTOCustomize()
{
	clearOmniture(s);
	s=s_gi(s_account);
	s.linkTrackVars="events";
	s.linkTrackEvents="event14";
	s.events="event14";
	s.tl(this,'o','CTO Customize');
	if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");
}

//
// Function to determine the store context (eVar20)
//
function getStoreContext(fcStoreId,storeId,logonId)
{
	var storeContext = "";
	//var storeId = getURLParameter("storeId");
	
	// Are we in Family Center?
	if (storeId == fcStoreId) storeContext="FCP";
	
	// Are we in Telesales?
	if (window.parent.name == "telesales" && (
		window.name=="CSR_ACTIONS" ||
		window.name=="CSR_STATUS" ||		
		window.name=="SONY_STYLE"))
	{
		var prefix = logonId.substr(0,2);
		// Is this a Retail Terminal?
		if (prefix=="ec" || prefix=="eb" || prefix=="rc")
			storeContext = "Retail";
		else
			storeContext = "Telesales";
	}	
	return storeContext;
}

function trackCartAccessory()
{
    clearOmniture(s);
	s=s_gi(s_account);
	s.linkTrackVars="events";
	s.linkTrackEvents="event15";
	s.events="event15";
	s.tl(this,'o','Cart Accessory');
	if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");
}
function trackCartEngraving()
{
    clearOmniture(s);
	s=s_gi(s_account);
	s.linkTrackVars="events";
	s.linkTrackEvents="event18";
	s.events="event18";
	s.tl(this,'o','Cart Engraving');
	if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");
}
function trackCartESP()
{
    clearOmniture(s);
	s=s_gi(s_account);
	s.linkTrackVars="events";
	s.linkTrackEvents="event16";
	s.events="event16";
	s.tl(this,'o','CartESP');
	if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");
}
function trackCartIS()
{
    clearOmniture(s);
	s=s_gi(s_account);
	s.linkTrackVars="events";
	s.linkTrackEvents="event19";
	s.events="event19";
	s.tl(this,'o','Cart IS');
	if (debugMode) window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");
}

var _cmspotObject = new Object();
var modulesDiv;
var divCollection;
_cmspotObject.SetupCMSpotTracking = function()
{
	modulesDiv = document.getElementById('modules');
	if ( modulesDiv != null)
	{
	divCollection = modulesDiv.getElementsByTagName("a");
	
        for (var i=0; i<divCollection.length; i++) {
		if (!divCollection[i].onclick)	{
		//divCollection[i].href = "#";
			divCollection[i].onclick = function(){
				var tag1 = this.getElementsByTagName("img");
				if (tag1[0] != undefined && tag1[0] != null && tag1[0] != "")
				{
					setCmsSpotPageImpressionsList(_cmspotObject.getIMGName(tag1[0]).toString());
					_cmspotObject.trackCMSOmniture(this.href, _cmspotObject.getIMGName(tag1[0]).toString());
					//trackCMSpot(_cmspotObject.getIMGName(tag1[0]).toString());
					//location.href=this.href;
					return false;
				}
			}
		}else {
			divCollection[i].functiondummy = divCollection[i].onclick;
			divCollection[i].onclick = function(){
				var tag1 = this.getElementsByTagName("img");
				if (tag1[0] != undefined && tag1[0] != null && tag1[0] != "")
				{
			 		setCmsSpotPageImpressionsList(_cmspotObject.getIMGName(tag1[0]).toString());
					_cmspotObject.trackCMSOmniture(this.href, _cmspotObject.getIMGName(tag1[0]).toString());
					//trackCMSpot(_cmspotObject.getIMGName(tag1[0]).toString());
					this.functiondummy();
					//location.href=this.href;
					return false;
				}else{
			 	this.functiondummy();
			 }
			}
        }
        }
	
	}
}

_cmspotObject.getIMGName = function (img_element){
	var string1 = img_element.src
	var len = string1.length
	var rs = 0
	for (i = len; i > 0; i--) {
	vb = string1.substring(i,i+1)
		if (vb == "/" && rs == 0) {
		return string1.substring(i+1,len)
		rs = 1
		}
	} 

}

_cmspotObject.trackCMSOmniture = function (var_link, var_code, var_isWindow, ev)
{
	trackCMSpot(var_code);
	
	var redirectFunction = (var_isWindow) ? (function () {window.open(var_link, '_blank');}) : (function () {location.href=var_link;});
	
	var timer = window.setTimeout(redirectFunction, 500);
}

//<!-- Start of methods for crmPortal-->
function trackCRMLoginAttempt() {
    if (typeof s != "undefined" && s != undefined) {
        clearOmniture(s);
    }
    s = s_gi(s_account);
    s.linkTrackVars = "events";
    s.linkTrackEvents = "event21";
    s.events = "event21";
    s.tl(this, "o", "CRM_Login_Attempt");
    if (debugMode) {
        window.open("", "stats_debugger", "width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></script><script language=\"JavaScript\">window.focus();</script>");
    }
}

function trackCRMPortalModule(obj, module, linkname) {
    clearOmniture(s);
    s = s_gi(s_account);
    s.linkTrackVars = "eVar26";
    s.linkTrackEvents = "None";
    s.eVar26 = module;
    s.tl(obj, "o", 'CRM' + '_'+ module +'_' + linkname);
    if (debugMode) {
        window.open("", "stats_debugger", "width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></script><script language=\"JavaScript\">window.focus();</script>");
    }
}

function trackCRMPortalExternalLinks(obj, module, linkname) {
    //clearOmniture(s);
    s = s_gi(s_account);
    s.tl(obj, "e", 'CRM' + '_'+ module +'_' + linkname);
    if (debugMode) {
        window.open("", "stats_debugger", "width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></script><script language=\"JavaScript\">window.focus();</script>");
    }
}

// Function for tracking Ratings and Reviews
// Function for tracking Ratings and Reviews
function pageChanged(pageName, pageStatus){
    if(typeof rateReviewSKU !='undefined'){
        trackProductTab(rateReviewSKU, pageName + ":" + pageStatus);
    }
    else{
       trackProductTab('Error_with_SKU', pageName + ":" + pageStatus);
    }
}
//<!-- End of methods for crmPortal -->

// TRACK NAV ITEMS

trackNav = function (var_link, var_code, var_isWindow, ev)
{
	trackMainNavSimple(var_code);
	
	if (!var_isWindow) {
		// Stop bubbling.
		Event.stop(ev);
		
		var redirectFunction = function () {location.href=var_link;};
		var timer = window.setTimeout(redirectFunction, 500);
	}
}

function trackSearchESupport(keyword,pageName)
{
	clearOmniture(s);
	setpageName(pageName);
	s=s_gi(s_account);
    s.linkTrackVars = "eVar34";
    s.linkTrackEvents = "None";	
	s.eVar34 = keyword;
	s.tl(this,'o',pageName);

    if (debugMode) {	
	    window.open("", "stats_debugger", "width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></script><script language=\"JavaScript\">window.focus();</script>");
    }
}

function trackSearchAlsoTry(pageName)
{
	//alert('trackSearchAlsoTry s_account'+s_account+'\npageName:'+pageName);		
	clearOmniture(s);
	setpageName(pageName);
	s=s_gi(s_account);
    s.linkTrackVars = "events";
    s.linkTrackEvents = "event17";		
	s.events="event17";
	s.tl(this,'o',pageName);
    if (debugMode) {	
	    window.open("", "stats_debugger", "width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></script><script language=\"JavaScript\">window.focus();</script>");
    }
}	

function trackSearchAddToCart(pageName)
{
	clearOmniture(s);
	setpageName(pageName);
	s=s_gi(s_account);
    s.linkTrackVars = "events";
    s.linkTrackEvents = "event26";	
	s.events="event26";
	s.tl(this,'o',pageName);
    if (debugMode) {	
	    window.open("", "stats_debugger", "width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></script><script language=\"JavaScript\">window.focus();</script>");
    }
}	

function trackSearchSortRefinement(sortRefinement,pageName)
{
	//alert('trackSearchSortRefinement s_account'+s_account+'\sortRefinement:'+sortRefinement+'\npageName:'+pageName);	
	clearOmniture(s);		
	setpageName(pageName);
	s=s_gi(s_account);
	s.linkTrackVars="eVar21,prop8";
	s.linkTrackEvents="None";
	s.prop8=sortRefinement;
	s.eVar21=s.prop8;
	s.tl(this,'o',pageName);
	if (debugMode) 
		window.open("", "stats_debugger", "width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></script><script language=\"JavaScript\">window.focus();</script>");
}

// Function for tracking the decision of the user during
// the proactive chat implementation.  Accept,Ignore, Decline
function userChatDecision(chatDecision){
	clearOmniture(s);
	s.linkTrackVars="prop24";
	s.linkTrackEvents="None";
	s.prop24=chatDecision;
	s.tl(this, 'o', 'Chat Decision');
	if (debugMode) 
		window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");	
}

// Function for tracking the clicks to the dynamic
// proactive chat button displayed once a business
// rule has been triggered and the user ignores or 
// declines the request
function userChatDynamicButton(buttonClicked){
	clearOmniture(s);
	s=s_gi(s_account);
	s.linkTrackVars="events";
	s.linkTrackEvents="event22";
	s.events="event22";
	s.tl(this,'o', 'Dynamic Chat Button Click');
	if (debugMode) 
		window.open("","stats_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" src=http://discover.store.sony.com/"http://192.168.112.2O7.net/stats_debugger.php/"></"+"script>" + "<script language=\"JavaScript\">window.focus();</script>");	
}
